package homework.exp05;

import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;

public class F {

    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("F.in")));
        } catch (Exception e) {
            cin = new Scanner(System.in);
        }
    }

    public static void main(String[] args) {
        while (cin.hasNext()) {
            String sa = cin.next();
            System.out.println(longestPalindrome(sa).length());
        }
    }


    static String preProcess(String s) {
        int n = s.length();
        if (n == 0) return "^$";

        StringBuilder ret = new StringBuilder("^");
        for (int i = 0; i < n; i++) {
            ret.append("#").append(s.substring(i, i + 1));
        }
        ret.append("#$");
        return ret.toString();
    }

    static public String longestPalindrome(String s) {
        String T = preProcess(s);
        int length = T.length();
        int[] p = new int[length];
        int C = 0, R = 0;
        for (int i = 1; i < length - 1; i++) {
            int i_mirror = C - (i - C);
            int diff = R - i;
            if (diff >= 0)//当前i在C和R之间，可以利用回文的对称属性
            {
                if (p[i_mirror] < diff)//i的对称点的回文长度在C的大回文范围内部
                {
                    p[i] = p[i_mirror];
                } else {
                    p[i] = diff;

                    while (T.charAt(i + p[i] + 1) == T.charAt(i - p[i] - 1)) {
                        p[i]++;
                    }
                    C = i;
                    R = i + p[i];
                }
            } else {
                p[i] = 0;
                while (T.charAt(i + p[i] + 1) == T.charAt(i - p[i] - 1)) {
                    p[i]++;
                }
                C = i;
                R = i + p[i];
            }
        }

        int maxLen = 0;
        int centerIndex = 0;
        for (int i = 1; i < length - 1; i++) {
            if (p[i] > maxLen) {
                maxLen = p[i];
                centerIndex = i;
            }
        }
        return s.substring((centerIndex - 1 - maxLen) / 2, (centerIndex - 1 - maxLen) / 2 + maxLen);
    }
}
